public class StringMap implements Map {

	// StringMap sm = new HashMap<String,String>;
	// Map<String,String> map;

	String key;
	Object o;
	StringMap next;
	static StringMap sm;
	static StringMap sm1;

	StringMap Kopf;

	public void put(String key, Object o) {

		StringMap sm_neu = new StringMap();
		sm_neu.key = key;
		sm_neu.o = o;

		sm_neu.next = sm.next;
		sm.next = sm_neu;

	}

	public Object get(String key) {

		Object o = new Object();

		if (find(key) != null) {
			o = find(key).o;
			return o;
		} else {
			o = null;
			return o;
		}
	}

	public Object remove(String key) {

		Object o = new Object();
		sm1 = sm;

		while (sm1.next != null) {

			if (key == sm1.next.key) {
				System.out.println("gefunden key " +key +" "+ sm1.next.o);
				// sm_neu.next.next.o = "geaendert";
				o = sm1.next;
				sm1.next = sm1.next.next;
				return o;
			}
			sm1 = sm1.next;
		}
		return o;
	}

	public StringMap find(String key) {
		// implement me!
		sm1 = sm;
		while (sm1.next != null) {

			if (key == sm1.next.key)
				//o = sm1.next;
				return sm1.next;
			sm1 = sm1.next;
		}
		return null;
	}

	public boolean contains(String key) {
		// StringMap e = ﬁnd(key);
		// return e != null;
		boolean b = true;
		return b;
	}

	public static void main(String[] args) {

		sm = new StringMap();
		//sm1 = new StringMap();
		sm.next = null;

		sm.put("1", "obj1");
		sm.put("2", "obj2");
		sm.put("3", "obj3");
		sm.put("4", "obj4");
		sm.put("5", "obj5");
		sm.put("6", "obj6");

		sm.remove("2");
		sm.remove("4");

		System.out.println("get(4) = " + sm.get("4"));
		System.out.println("get(1) = " + sm.get("1"));
		System.out.println("get(3) = " + sm.get("3"));
		System.out.println("get(2) = " + sm.get("2"));
		System.out.println("get(5) = " + sm.get("5"));
		System.out.println("get(6) = " + sm.get("6"));
		
		System.out.println("");

		
		System.out.println("wie sieht jetzt sm aus:");
		while (sm.next != null) {			
			System.out.println("get(" + ") " + sm.next.o);

			sm = sm.next;
		}

	}

}
